<legend><?php echo ucfirst($txt->getWord('map')); ?></legend><br />
<div id="mapLocation">
	<?php 
	if((GOOGLE_API_KEY != '') && ($adc->getCurrentAd()))
	{
		$ggc = new GoogleGeoCode(GOOGLE_API_KEY);
		$ggc->setAddress($adc->CurrentAd->getLocationCity().', '.$adc->CurrentAd->getLocationCountryName());
		//echo $ggc->getAddress();
		if($ggc->getCoords() == '')
		{ $ggc->setAddress($adc->CurrentAd->getLocationZip().' '.$adc->CurrentAd->getLocationCity()); }
		// https://maps.google.com/maps?q=Norway,+Oslo&hl=no&sll=37.0625,-95.677068&sspn=52.68309,114.169922&t=h&hnear=Oslo,+Norge&z=11
		if($ggc->getCoords() != '')
		{
			$adc->getCurrentAd()->setLocationCoords($ggc->getCoords());
			echo '<div id="googleMapCanvas" style="width:'.$adc->getSetting('GoogleMapW').'px; height:'.$adc->getSetting('GoogleMapH').'px;"></div>';
		?>
		<script type="text/javascript">
		function initialize() {
		  var myOptions = {
			zoom: 7,
			center: new google.maps.LatLng(<?php echo $ggc->getCoords(); ?>),
			mapTypeId: google.maps.MapTypeId.ROADMAP
		  }
		  
		  var map = new google.maps.Map(document.getElementById("googleMapCanvas"), myOptions);
		  
		  var marker = new google.maps.Marker({
			map: map,
			position: map.getCenter(),
			clickable: true,
			title: '<?php echo $adc->CurrentAd->getLocationAddress().', '.$adc->CurrentAd->getLocationZip().' '.$adc->CurrentAd->getLocationCity(); ?>'
			}); 
		}
		jQuery(document).ready(function() 
		{ initialize(); });
		</script>
        <?php 
		if($ggc->getCoords() != '')  
		{
			/*
			$mapUrl  = 'http://maps.google.com/maps?';
			$mapUrl .= 'q='.str_replace(' ', '+', $adc->CurrentAd->getLocationAddress())
			$mapUrl .= ''
			$mapUrl .= ''
			$mapUrl .= ''
			$adc->CurrentAd->getLocationAddress().', '.$adc->CurrentAd->getLocationZip().' '.$adc->CurrentAd->getLocationCity()
			http://maps.google.com/maps?q=Heimdalsveien+3++7080+HEIMDAL&hl=no-NO&ie=UTF8&sll=63.350356,10.355534&sspn=0.029451,0.111494&hnear=Heimdalsvegen+3,+7080,+Trondheim,+S%C3%B8r-Tr%C3%B8ndelag,+Norway&t=m&z=16&iwloc=A
			*/
			?><br /><a target="_blank" href="http://maps.google.com/maps?ll=<?php echo str_replace(', ', ',', $ggc->getCoords()); ?>&z=14&t=m&hl=no-NO">Klikk her for st&oslash;rre kart.</a>
			<?php 
		}
		
		}
	}
	?>
    <input name="LocationCoords" type="hidden" value="<?php echo $ggc->getCoords(); ?>">
</div>